package com.romotc.qqrobot.webqq.qqInterfaceCall;

import java.util.ArrayList;

import org.json.JSONObject;

import com.romotc.qqrobot.bean.QQLogedin;
import com.romotc.scache.httpreq;

/**
 * 修改备注 http://s.web2.qq.com/api/change_mark_name2
 * @author Administrator
 * 正常的返回信息  {"retcode":0,"result":{"result":0}}
 */
public class Change_mark_name2_InterCall extends QQInterfaceCall {

	public static final String Key_Must_Input_Tuin = "tuin";
	public static final String Key_Input_Markname = "chg2MarkName";

	private static Change_mark_name2_InterCall instance;
	public static synchronized Change_mark_name2_InterCall getInstance()
	{
		if(instance == null)
			instance = new Change_mark_name2_InterCall();
		return instance;
	}
	@Override
	public String buildReqBody(JSONObject reqDataObj, QQLogedin loginQQ)
			throws Exception {
		StringBuilder bld = new StringBuilder();
		bld.append("tuin=").append(reqDataObj.get(Key_Must_Input_Tuin));
		bld.append("&markname=").append(reqDataObj.optString(Key_Input_Markname, ""));
		bld.append("&vfwebqq=").append(loginQQ.getVfwebqq());
		return bld.toString();
	}

	@Override
	public int getLogLevel() {
		return 1001;
	}

	@Override
	public String getReqUrl(JSONObject reqDataObj, QQLogedin loginQQ) throws Exception {
		return "http://s.web2.qq.com/api/change_mark_name2";
	}

	@Override
	public int getReq_method() {
		return httpreq.REQUEST_POST;
	}

	@Override
	public boolean hasPreCall(QQLogedin loginQQ, JSONObject reqDataObj) {
		return false;
	}

	@Override
	public ArrayList<String> myReqHeaders(int reqBodyLen, QQLogedin loginQQ,JSONObject reqDataObj) {
		ArrayList<String> s = buildReqHeaders(reqBodyLen, loginQQ,
				"http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=2", 
				"s.web2.qq.com", "http://s.web2.qq.com");
		//调用后返回{"retcode":100001}问题
		s.add("Content-Type: application/x-www-form-urlencoded");
		return s;
	}

	@Override
	public JSONObject preCall(QQLogedin loginQQ, JSONObject reqDataObj)
			throws Exception {
		return null;
	}

}
